package com.googlecode.lightest.core

/**
 * Subclasses can provide all necessary contextual information for running a
 * Lightest test.
 */
class LightestContextAware {
    ITaskDispatcher dispatcher

    /**
     * Returns the thread context as provided by the dispatcher, which must
     * be set.
     */
    LightestContext getContext() {
        assert dispatcher != null
        return dispatcher.getContext()
    }

    /**
     * Returns the thread preferences from the context provided by the
     * dispatcher, which must be set.
     */
    IPreferences getPrefs() {
        return getContext().getPrefs()
    }

    /**
     * Returns the thread environment from the context provided by the
     * dispatcher, which must be set.
     */
    ITestEnvironment getEnv() {
        return getContext().getEnv()
    }
}

